import { defineStore } from 'pinia'
import { ElMessage } from 'element-plus'

export const useAppStore = defineStore('app', {
  state: () => ({
    theme: 'light',
    loading: false,
    user: null as any,
    notification: {
      show: false,
      message: '',
      type: 'info' as 'success' | 'warning' | 'info' | 'error'
    }
  }),
  
  actions: {
    setTheme(theme: string) {
      this.theme = theme
    },
    setLoading(loading: boolean) {
      this.loading = loading
    },
    setUser(user: any) {
      this.user = user
    },
    showSuccess(message: string) {
      ElMessage.success(message)
    },
    showError(message: string) {
      ElMessage.error(message)
    },
    showWarning(message: string) {
      ElMessage.warning(message)
    },
    showInfo(message: string) {
      ElMessage.info(message)
    }
  },
  
  getters: {
    isDarkMode: (state) => state.theme === 'dark',
    isLoggedIn: (state) => !!state.user
  }
}) 